import 'package:spring_fairy/model/user.dart';

import 'mood_track.dart';

class MoodDiary {
  int? id;
  int? userId;
  int? trackId;
  DateTime? diaryDate;
  String? title;
  String? content;
  String? moodSummary;
  DateTime? createdAt;

  MoodDiary({
    this.id,
    this.userId,
    this.trackId,
    this.diaryDate,
    this.title,
    this.content,
    this.moodSummary,
    this.createdAt,
  });

  factory MoodDiary.fromJson(Map<String, dynamic> json) => MoodDiary(
    id: json['id'],
    userId: json['user'],
    trackId: json['track'] ,
    diaryDate: json['diaryDate'] != null ? DateTime.parse(json['diaryDate']) : null,
    title: json['title'],
    content: json['content'],
    moodSummary: json['moodSummary'],
    createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null,
  );

  Map<String, dynamic> toJson() => {
    'id': id,
    'user': userId,
    'track': trackId,
    'diaryDate': diaryDate?.toIso8601String(),
    'title': title,
    'content': content,
    'moodSummary': moodSummary,
    'createdAt': createdAt?.toIso8601String(),
  };
}
